/*
 * Beste naber? :)
 * iyiliiik :)
 * 
 */
package besteninilkprojesi;

/**
 *
 * @author ASUS
 */
public class BesteninIlkProjesi {

    public static void main(String[] args) {

        System.out.println(printTriangle(4, 3));
        for (int i : primeNumbers(3000)) {
            System.out.println(i);
        }
        Point2D firstPoint = new Point2D(2, 3);
        Point2D secondPoint = new Point2D(7, 15);
        System.out.println("Distance from first point to second point is " + firstPoint.distance(secondPoint));

    }

    public static String printTriangle(int floor, int high) {
        String tri = "";
        int distance = ((floor - 1) / high) + 1;
        int b = 0;
        for (int a = 1; a <= floor; a = a + distance) {
            int m;
            for (m = 1; m <= a; m++) {

                tri += "*";

            }
            if (b == high - 1) {
                for (int c = 0; c <= floor - m; c++) {

                    tri += "*";
                }
            }
            tri += "\n";
            b++;


        }
        if (b < high) {
            for (int p = 1; p <= floor; p++) {

                tri += "*";

            }
        }
        return tri;
    }

    public static boolean isPrime(int number) {
        for (int n = 2; n < number; n++) {
            if ((number % n) == 0) {
                return false;
            }
        }
        return true;
    }

    public static int[] primeNumbers(int max) {
        int[] simpleArray = new int[max];
        int b = 0;
        for(int a=2; a<=max; a++)
        {
            if (isPrime(a)) {
            simpleArray[b] = a;
            b++;
        }

        }

        int[] mainArray = new int[b];
        System.arraycopy(simpleArray, 0, mainArray, 0, b);
        return mainArray;

    }
}

